package com.lanchetech.im.config;

import com.lanchetech.im.service.ImService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.yeauty.standard.ServerEndpointExporter;

/**
 * 开启WebSocket支持
 *
 * @author zhengkai
 */
@Configuration
public class WebSocketConfig {

    /**
     * 因 SpringBoot WebSocket 对每个客户端连接都会创建一个 WebSocketServer（@ServerEndpoint 注解对应的） 对象，Bean 注入操作会被直接略过，因而手动注入一个全局变量
     *
     * @param imService
     */
    @Autowired
    public void setMessageService(ImService imService) {
        WebSocketServer.imService = imService;
    }
}
